#!/bin/bash

### BEGIN INIT INFO
# Provides:          mini_binlsrv
# Required-Start:    $local_fs $syslog $network
# Required-Stop:     $local_fs $syslog $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: mini binl server
# Description:       mini binl server
### END INIT INFO


home=/opt/pxe-ris-winxp
log=/var/log/mini-binlsrv.log
pid=/var/run/mini-binlsrv.pid

if [ "$1" == "start" ]; then
(
    cd "$home"
    cd rislinux
    nohup ./binlsrv &> "$log" &
    echo $! > "$pid"
)
elif [ "$1" == "stop" ]; then
(
    kill "$(cat "$pid")" && rm "$pid"
)
else
    echo "Usage: $0 start | stop"
fi

